/**
 * Copyright (c) 2014-2015, Suredy technology Co., Ltd. All rights reserved.
 * 
 * @author ZhangMaoren
 * @since 2015年4月13日
 * @version 0.1
 */
package com.suredy.base.model;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

/**
 * @author ZhangMaoren
 *
 */
@Entity
@Table(name = "T_SECURITY_PERMISSION")
public class Permission implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 7135822368851983710L;
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "ID")
	private Long id;
	
	@Column(name = "RESOURCEID")
	private Long resourceId; // resource id;
	
	@Column(name = "ACTION")
	private Action action; // 资源访问方式

	
	
	
	/**
	 * @return the id
	 */
	public Long getId() {
		return id;
	}

	
	/**
	 * @param id the id to set
	 */
	public void setId(Long id) {
		this.id = id;
	}

	
	/**
	 * @return the resourceId
	 */
	public Long getResourceId() {
		return resourceId;
	}

	
	/**
	 * @param resourceId the resourceId to set
	 */
	public void setResourceId(Long resourceId) {
		this.resourceId = resourceId;
	}

	
	/**
	 * @return the action
	 */
	public Action getAction() {
		return action;
	}

	
	/**
	 * @param action the action to set
	 */
	public void setAction(Action action) {
		this.action = action;
	}

	@Override
	public boolean equals(Object o) {
		if (this == o)
			return true;
		if (o == null || getClass() != o.getClass())
			return false;

		Permission p = (Permission) o;

		if (id != null ? !id.equals(p.id) : p.id != null) {
			return false;
		}

		if (resourceId != null ? !resourceId.equals(p.resourceId) : p.resourceId != null) {
			return false;
		}
		if (action != null ? !action.equals(p.action) : p.action != null) {
			return false;
		}

		return true;
	}

	@Override
	public int hashCode() {
		return ((id != null ? id.hashCode() : 0) + (resourceId != null ? resourceId.hashCode() : 0) + (action != null ? action.hashCode() : 0));
	}

	@Override
	public String toString() {
		return "Permisssion[" + "id=" + id + ", resourceId='" + resourceId + "\'" + ", action='" + action.getDescription() + "\'" + "]";
	}
}
